﻿package mortal.game.manager
{
    import com.gengine.global.*;
    import com.gengine.utils.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.game.*;
    import mortal.game.control.subControl.*;
    import mortal.game.manager.mouse.*;
    import mortal.game.view.systemSetting.*;

    public class MouseRightClickManager extends Object
    {
        private static var _instance:MouseRightClickManager;

        public function MouseRightClickManager()
        {
            return;
        }// end function

        public function run() : void
        {
            Global.stage.addEventListener("rightMouseDown", this.onRightClick);
            return;
        }// end function

        public function stop() : void
        {
            Global.stage.removeEventListener("rightMouseDown", this.onRightClick);
            return;
        }// end function

        private function onRightClick(event:MouseEvent) : void
        {
            var _loc_2:MouseEvent = null;
            if (event.target == Global.stage)
            {
                if (!Game.scene || !Game.scene.getMouseEnabled())
                {
                    return;
                }
                Scene3DClickProcessor.instance.work(event);
                if (FlashVersion.instance.isVersionMeet(11, 2))
                {
                    MouseRightLongPress.instance.setMouseDown();
                }
            }
            else if (SystemSetting.instance.mouseRightUIKey.bValue)
            {
                _loc_2 = new MouseEvent(MouseEvent.DOUBLE_CLICK, true, false, event.localX, event.localY, event.relatedObject, event.ctrlKey, event.altKey, event.shiftKey, event.buttonDown, event.delta);
                (event.target as InteractiveObject).dispatchEvent(_loc_2);
            }
            return;
        }// end function

        public static function get instance() : MouseRightClickManager
        {
            if (!_instance)
            {
                _instance = new MouseRightClickManager;
            }
            return _instance;
        }// end function

    }
}
